import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Box-ConstrainedBox-限定最大最小宽高容器',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Box-ConstrainedBox-限定最大最小宽高容器'),
        ),
          //撑下去
          body: Center(
            child: Column(
              children: [
                Container(
                  width: 50,
                  height: 50,
                  color: Colors.red,
                  child: Text('50 50'),
                ),
                SizedBox(
                  height: 20.0,
                ),
                Container(
                  width: 100,
                  height: 100,
                  color: Colors.red,
                  child: Text('100 100'),
                ),
                SizedBox(
                  height: 20.0,
                ),

                ConstrainedBox(constraints: const BoxConstraints(
                    minWidth: 50,
                  minHeight: 50,
                  maxHeight: 100,
                  maxWidth: 100,
                ),
                  child: Container(
                    width: 150,//裁剪成100
                    height: 80,
                    child: Text('150  80',style: TextStyle(color: Colors.blue),),
                    color: Colors.red,
                  ),
                ),

                SizedBox(
                  height: 20.0,
                ),
                ConstrainedBox(constraints: const BoxConstraints(
                  minWidth: 50,
                  minHeight: 50,
                  maxHeight: 100,
                  maxWidth: 100,
                ),
                  child: Container(
                    width: 40,//裁剪成100
                    height: 40,
                    child: Text('40  40',style: TextStyle(color: Colors.blue),),
                    color: Colors.yellow,
                  ),
                ),
                SizedBox(
                  height: 20.0,
                ),
                ConstrainedBox(constraints: const BoxConstraints(
                  minWidth: 20,
                  minHeight: 20,
                  maxHeight: 100,
                  maxWidth: 100,
                ),
                  child: Container(
                    width: 150,//裁剪成100
                    height: 150,
                    child: Text('150  150',style: TextStyle(color: Colors.blue),),
                    color: Colors.yellow,
                  ),
                ),
              ],
            ),
          )
      ),
    );
  }
}

